﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autofac;
using Autofac.Builder;
using EvidenceManagement.ViewModel.Common;
using EvidenceManagement.ViewModel.Security;
using EvidenceManagement.PresentationModel.Common;
using EvidenceManagement.PresentationModel.Security;
using EvidenceManagement.Workstation.Security;
using EvidenceManagement.Workstation;

namespace EvidenceManagement.Workstation
{
    public static class AutofacContainerBuilder
    {
        /// <summary>
        /// Configures and builds Autofac IOC container.
        /// </summary>
        /// <returns></returns>
        public static IContainer BuildContainer()
        {
            var containerBuilder = new ContainerBuilder();

            //MasterView registration
            //containerBuilder.RegisterType<frmMainForm>().As<IMasterView>();
            containerBuilder.RegisterType<MasterPresenter>().As<IMasterPresenter>();
            
            //LogOn registration
            containerBuilder.RegisterType<frmLogin>().As<ILogOnView>();
            containerBuilder.RegisterType<LogOnPresenter>().As<ILogOnPresenter>();
                        
            containerBuilder.RegisterType<frmRegisterUser>().As<IRegisterUserView>();
            containerBuilder.RegisterType<RegisterUserPresenter>().As<IRegisterUserPresenter>();

            // build container
            var container = containerBuilder.Build(Autofac.Builder.ContainerBuildOptions.Default);
            return Container = container;            
        }

        public static IContainer Container
        {
            get;
            private set;
        }
    }
}
